<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div>
    <form action="/user/login" method="post" style="align-content: center">
        <label for="username"></label><input type="text" id="username" placeholder="用户名">
        <br>
        <label for="password"></label><input type="password" id="password" placeholder="密码">
        <br>
        <button id="bt" type="button">登录</button>
    </form>
</div>

</body>
<script type="text/javascript">

    $(function () {
        $("#bt").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            $.ajax({
                type: "post",
                url: "/user/login",
                dataType: "json",
                contentType: "application/json",
                data: JSON.stringify({"userName": username, "password": password}),
                success: function (res) {
                    if ("200"===res.errorCode){
                        window.location.href = "/index";
                    }else {
                        alert(res.message)
                    }
                }
            });
        })
    });

</script>
</html>